﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="category.aspx.cs" Inherits="__admin_category" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <style type="text/css">
    .placeholder
    {
        height: 60px
    } 
    </style>

    <script src="/script/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="/script/jquery.blockUI.js" type="text/javascript" ></script>
    <script src="/script/jquery-ui-1.8.12.custom.min.js" type="text/javascript" ></script>
    

    <script type="text/javascript">
        $(document).ready(function () {
            $("#AttributesView").sortable(
            {
                axis: 'y',
                cursor: 'move',
                helper: "clone",
                opacity: 0.6,
                placeholder: "placeholder",
                start: function (event, ui) {
                    ui.helper.css("border", "1px solid black");
                    ui.helper.css("background", "LightGrey");
                },
                update: function (event, ui) {
                    //$.blockUI({ message: "The page is being updated. Please wait..." });
                    $.blockUI();
                    var s = $(this).sortable('toArray').toString();

                    $.ajax({
                        type: "POST",
                        url: "/myApp/DataSourceService.svc/AttributesOrder_Update",
                        cache: false,
                        data: JSON.stringify({ attributes: s }),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (data) {
                            $.unblockUI;
                            location.reload();
                        },
                        error: function () {
                            alert("The operation caused an error");
                            $.unblockUI;
                            location.reload();
                        }
                    });

                }
            }
            )
        });

        function GetNum(cat) {
            alert(cat);
        }

        function Attributes_ChangeOrder(catID, firstID, secondID) {
                $.blockUI();
                $.ajax({
                    type: "POST",
                    url: "/../myApp/DataSourceService.svc/Attributes_ChangeOrder",
                    cache: false,
                    data: JSON.stringify({ categoryID: catID, firstRowID: firstID, secondRowID: secondID }),
                    contentType: "application/json; charset=utf-8",

                    dataType: "json",
                    success: function (data) {
                        $.unblockUI;
                        window.location = "/myApp/root/admin/category.aspx/" + catID;
                    },
                    error: function () {
                        $.unblockUI;
                        alert("error");
                        window.location = "/myApp/root/admin/category.aspx/" + catID;
                    }

                });

            }
    </script>

</head>
<body>
    <form runat="server">

    <octo:FormView ID="FormView" Caption="Category Info" runat="server">

        <octo:FormRow Required="true" OnServerValidate="NameValidate" Label="Category Name" runat="server">
            <octo:InputText ID="CategoryName" MaxLength="100" Required="true" runat="server" />
        </octo:FormRow>

        <octo:FormRow Label="Parent Category" runat="server">
            <asp:DropDownList ID="ParentCategory" runat="server" />
        </octo:FormRow>

        <octo:FormRow Label="Ad Name Example" runat="server">
            <octo:InputText ID="AdNameExample" MaxLength="512" runat="server" />
        </octo:FormRow>

        <octo:FormRow Label="ImageURL" runat="server">
            <octo:InputUrl ID="ImageURL" MaxLength="512" runat="server" />
        </octo:FormRow>

        <octo:FormRow Label="RedirectURL" runat="server">
            <octo:InputUrl ID="RedirectURL" MaxLength="512" runat="server" />
        </octo:FormRow>

        <octo:FormRow runat="server">
            <octo:CheckBox ID="ReadOnly" Text="Read Only" runat="server" />
        </octo:FormRow>

    </octo:FormView>

    <octo:FormView ID="AttributesView" Visible="false" Caption="Category Attributes" runat="server">

       

    </octo:FormView>

    </form>
</body>
</html>
